<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="/template/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundle.EdituserTitle}"></h:outputText>
        </ui:define>
        <ui:define name="content">
            <h:panelGroup id="messagePanel" layout="block">
                <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
            </h:panelGroup>
            <h:form>
                <h:panelGrid columns="2">
                    <h:outputLabel value="#{bundle.EdituserLabel_firstName}" for="firstName" />
                    <h:inputText id="firstName" value="#{userController.selected.firstName}" title="#{bundle.EdituserTitle_firstName}" />
                    <h:outputLabel value="#{bundle.EdituserLabel_lastName}" for="lastName" />
                    <h:inputText id="lastName" value="#{userController.selected.lastName}" title="#{bundle.EdituserTitle_lastName}" />
                    <h:outputLabel value="#{bundle.EdituserLabel_login}" for="login" />
                    <h:inputText id="login" value="#{userController.selected.login}" title="#{bundle.EdituserTitle_login}" required="true"/>
                    <h:outputLabel value="#{bundle.EdituserLabel_password}" for="password" />
                    <h:inputSecret id="password" value="#{userController.selected.password}" title="#{bundle.EdituserTitle_password}" required="true"/>
                    <h:outputLabel value="#{bundle.UserRole}" for="role" rendered="#{userRights.admin}"/>
                    <h:selectManyCheckbox id="role" value="#{userController.selectedRoleList}" rendered="#{userRights.admin}">
                        <f:selectItems value="#{userController.roleSelectItems}" 
                                       var="item"
                                       itemLabel="#{item.idRole.name}"
                                       itemValue="#{item.id}" />
                    </h:selectManyCheckbox>
                </h:panelGrid>
                <h:commandLink action="#{userController.update}" value="#{bundle.EdituserSaveLink}"/>
                <br />
                <br />
                <h:commandLink action="#{userController.prepareList()}" value="#{bundle.EdituserShowAllLink}" 
                               immediate="true" rendered="#{userRights.admin || userRights.moderator}"/>
            </h:form>
        </ui:define>
    </ui:composition>

</html>
